home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / xcmd / dxcmds34.sit / Dartmouth XCMD's 3.4.3 / card_20423.txt < prev    next >
Text File  |  1990-04-17  |  4KB  |  197 lines

  1. -- card: 20423 from stack: in.3
  2. -- bmap block id: 20783
  3. -- flags: 4000
  4. -- background id: 7836
  5. -- name: ChooserName
  6. ----- HyperTalk script -----
  7. on opencard
  8.   global nextPos
  9.   hide card field "source"
  10.   set the scroll of card field "documentation" to 0
  11.   put 0 into nextPos
  12.   pass opencard
  13. end opencard
  14.  
  15. on Install
  16.   get ChooseTargetStack()
  17.   InstallResource XFCN,ChooserName,it
  18. end Install
  19.  
  20.  
  21. -- part 3 (button)
  22. -- low flags: 00
  23. -- high flags: A003
  24. -- rect: left=76 top=298 right=320 bottom=176
  25. -- title width / last selected line: 0
  26. -- icon id / first selected line: 0 / 0
  27. -- text alignment: 1
  28. -- font id: 0
  29. -- text size: 12
  30. -- style flags: 0
  31. -- line height: 16
  32. -- part name: Try It
  33. ----- HyperTalk script -----
  34. on mouseUp
  35.   get ChooserName()
  36.   answer "ChooserName is: "&it
  37. end mouseUp
  38.  
  39.  
  40.  
  41. -- part 5 (field)
  42. -- low flags: 01
  43. -- high flags: 2007
  44. -- rect: left=18 top=32 right=288 bottom=480
  45. -- title width / last selected line: 0
  46. -- icon id / first selected line: 0 / 0
  47. -- text alignment: 0
  48. -- font id: 3
  49. -- text size: 10
  50. -- style flags: 0
  51. -- line height: 13
  52. -- part name: Documentation
  53.  
  54.  
  55. -- part 8 (field)
  56. -- low flags: 81
  57. -- high flags: 0007
  58. -- rect: left=18 top=31 right=289 bottom=492
  59. -- title width / last selected line: 0
  60. -- icon id / first selected line: 0 / 0
  61. -- text alignment: 0
  62. -- font id: 3
  63. -- text size: 10
  64. -- style flags: 0
  65. -- line height: 13
  66. -- part name: source
  67.  
  68.  
  69. -- part 10 (button)
  70. -- low flags: 00
  71. -- high flags: 8003
  72. -- rect: left=304 top=299 right=321 bottom=425
  73. -- title width / last selected line: 0
  74. -- icon id / first selected line: 0 / 0
  75. -- text alignment: 1
  76. -- font id: 0
  77. -- text size: 12
  78. -- style flags: 0
  79. -- line height: 16
  80. -- part name: Show C Source
  81. ----- HyperTalk script -----
  82. on mouseUp
  83.   get the visible of card field "source"
  84.   set the visible of card field "source" to not it
  85.   if it is false then
  86.     set the name of me to "Hide C Source"
  87.   else
  88.     set the name of me to "Show C Source"
  89.   end if
  90. end mouseUp
  91.  
  92.  
  93.  
  94. -- part contents for card part 5
  95. ----- text -----
  96. ChooserName 1.0
  97. Roger Brown
  98.  
  99. ChooserName is an XFCN that returns the currently stored choose name.
  100.  
  101. Syntax is:  get ChooserName()
  102.  
  103.  
  104. REVISION HISTORY
  105. 1.0  9/6/89 First public release.
  106.  
  107. -- part contents for card part 8
  108. ----- text -----
  109. /* program ChooserName1.0d0.c */
  110. /* XCMD version */
  111.  
  112.  
  113. /* ChooserName is a HyperCard XFCN that simply returns the chooser name.
  114.    
  115.    
  116.     Syntax is:
  117.    
  118.         get ChooserName()
  119.    
  120.                    
  121.     To compile: create a project with this and MacTraps. Build as code resource type
  122.                   XFCN named ChooserName.
  123.  
  124. /* globals */
  125.  
  126.  
  127. #define CHOOSERID -16096        /* resource id of the chooser name 'STR ' resource */
  128.  
  129. #include "stddata_ctype.c"
  130. #include "strings.c"
  131. #include "HyperXCmd.h"
  132. #include "XCmdGlue.inc.c"
  133. #include "SetUpA4.h"
  134.  
  135. /* -------------------- CfromPstrHandle -------------------- */
  136.  
  137. /* copy P string in handle h into c string s */
  138.  
  139. CfromPstrHandle(s,h)
  140. char *s;
  141. Handle h;
  142. {
  143.   int len,c;
  144.   
  145.   len = (int)**h;                  /* get length in first byte */
  146.   for (c=0;c<len;c++) s[c] = *(*h+c+1);  /* move bytes to string */
  147.   s[len] = 0;                            /* mark end of string */
  148. }
  149.  
  150. /* -------------------- GetChooserName -------------------- */
  151.  
  152. /* get the chooser name */
  153.  
  154. GetChooserName(name)
  155. char *name;
  156. {
  157.   Handle sH;
  158.   
  159.   sH = GetResource('STR ',CHOOSERID);     /* it lives here */
  160.   if (sH==NULL) {
  161.     /* can't find one */
  162.     strcpy(name,"No Chooser Name.");
  163.     return;
  164.   }
  165.   else CfromPstrHandle(name,sH);
  166. }
  167.  
  168.  
  169. ResultIs(paramPtr,theResult)
  170. XCmdBlockPtr  paramPtr;
  171. char *theResult;
  172. {
  173.   long len;
  174.   Handle resultHandle;
  175.   len = 1+strlen(theResult);
  176.   resultHandle = NewHandle(len);
  177.   BlockMove(theResult,*resultHandle,len);
  178.   paramPtr->returnValue = resultHandle;
  179. }
  180.  
  181. /* XCMD entry point */
  182.  
  183. pascal void main(paramPtr)
  184. XCmdBlockPtr  paramPtr;
  185. {
  186.   Handle taskHandle;
  187.   Str255 temp;
  188.   
  189.   RememberA0();
  190.   SetUpA4();  
  191.   GetChooserName(temp); 
  192.   ResultIs(paramPtr,temp);
  193.   RestoreA4();
  194.   return;
  195. }
  196.  
  197.